package
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.geom.Point;

	public class muchie extends MovieClip
	{
		public var nodStanga:nod;
		public var nodDreapta:nod;
		
		public function muchie(st:nod,dr:nod)
		{
			nodStanga = st;
			nodDreapta = dr;		
			st.addMuchie(this);
			if( dr.addMuchie(this) )
				deseneaza();
			
			this.doubleClickEnabled=true;
			
			this.addEventListener(MouseEvent.DOUBLE_CLICK,stergeMuchie);
		}
		
		public function deseneaza():void
		{
			graphics.clear();
			
			graphics.lineStyle(3,0xbbcedd,0.9);
			graphics.moveTo(nodStanga.x + nodStanga.nWidth / 2, nodStanga.y + nodStanga.nHeight / 2);
			graphics.lineTo(nodDreapta.x + nodDreapta.nWidth / 2, nodDreapta.y + nodDreapta.nHeight / 2);
		}
		
		public function stergeMuchie(e:MouseEvent):void
		{
			nodStanga.stergeVecin(nodDreapta);
			nodDreapta.stergeVecin(nodStanga);
			
			this.parent.removeChildAt(this.parent.getChildIndex(this));
		}
	}
}